home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / fdk.zip / FDK.DOC < prev    next >
Text File  |  1988-05-24  |  13KB  |  270 lines

  1.  
  2.                           Filter Development Kit
  3.                         (C) 1988 -- Chris E. Greer
  4.  
  5.  
  6. NOTICE: This software may be used and freely copied for personal use only. 
  7.         Any commercial or business use requires permission of the author.
  8.         The author makes no guarantees about the operation of the software,
  9.         and cannot be held liable for any problems or loss resulting from
  10.         the use or misuse of this software.
  11.  
  12.  
  13.  
  14.  
  15.                                 Overview
  16.  
  17.    The Filter Development Kit is a project that grew out of my desire to
  18. try out my new copy of Turbo C, and to learn the C language in general. 
  19. What it consists of, essentially, is two separate programs that can be used
  20. to create many different kinds of DOS filters.  By a filter, I refer to a
  21. program that takes a stream of characters as input, changes them in some
  22. way, and outputs the changed stream.  An example of a filter is a program
  23. that strips off the high bit of all the characters in a stream.  A filter
  24. may also change lowercase characters to uppercase, or strip all the form
  25. feeds from a stream.  All these types of filters can be created with FDK.
  26.  
  27.    Although filters can be pretty complex, such as the SORT, FIND, and MORE
  28. filters supplied with DOS, the filters created by the FDK are primarily
  29. substitution filters.  A swap table is maintained by the filter, and any
  30. character can be mapped to any other character, or simply removed from the
  31. stream altogether.  In other words, you can set up the filter so that every
  32. time an 'A' is encountered on the input stream, an 'a' is substituted for
  33. it.  This would have the effect of changing all uppercase A's to lowercase.
  34.  
  35.     In addition to character substitution, the FDK also gives you the
  36. option of completely removing NULLs, or characters with a value of 0, from
  37. the stream.  Thus, by mapping any unwanted character or characters to NULL,
  38. and then stripping NULLs from the stream, you can delete unwanted
  39. characters from the stream.
  40.  
  41.     The final option available is the expansion of tabs into spaces.  Tab
  42. 'stops' can be set at any interval you want, and any tabs encountered in
  43. the input stream would be turned into spaces up to the next tab stop.
  44.  
  45.  
  46.  
  47.                             Creating a Filter
  48.  
  49.    The two files needed to create a filter are FDK.EXE and FILTER.EXE. 
  50. FDK.EXE is the program that allows you to modify the swap table and set the
  51. NULL and TAB options for your new filter.  FILTER.EXE is the template
  52. filter; actually, it is a 'non-filter' - nothing has been remapped in the
  53. swap table, and NULLs and TABs are passed through unaffected, but it still
  54. is a working filter.  Although you can use any filter created by FDK as a
  55. template filter, it's still best to keep this one around when you need to
  56. start from scratch.
  57.  
  58.    Using FDK is fairly simple.  To create a filter, make sure FDK.EXE and
  59. the template filter are in the same directory, or at least that the
  60. template filter is in the current directory and FDK.EXE is available
  61. through the current PATH setting.  Enter the following at the DOS prompt:
  62.  
  63.     FDK <template> <newfilter>
  64.  
  65. where <template> is the name of an existing filter created by FDK, and
  66. <newfilter> is the name of the new filter you are creating.  Both must be
  67. valid DOS file names, both must have the extension .EXE, and they cannot be
  68. the same name (i.e., the command: FDK filter.exe filter.exe will generate
  69. an error.  For example, to use FILTER.EXE as the template, and to create a
  70. filter named UPPER.EXE, enter the following:
  71.  
  72.     FDK filter.exe upper.exe
  73.     
  74. The template filter is read, and the current settings for the low-order
  75. bytes of the swap table will be displayed.  Each column has two numbers;
  76. the left one is the input value, which can't be changed.  The right number
  77. is the substitution character and can be changed to any one-byte value you
  78. choose (00-FF).  You can move through the table using the following editing
  79. keys, and remap any character as desired.
  80.  
  81.       Editing Keys:
  82.  
  83.         Arrow keys        move in the direction of the arrows
  84.  
  85.         Tab, Shift-Tab        move right or left one column
  86.  
  87.         PgUp, PgDn        move to top or bottom of current
  88.                     column
  89.  
  90.         Home, End        move to upper left and lower right
  91.                     characters of the displayed table
  92.  
  93.         F1            toggles between low-order charac-
  94.                     ters (00 - 7F) and high-order
  95.                     characters (80 - FF)
  96.  
  97.         F10            toggles between fast and slow
  98.                     screen updates.  Fast is the
  99.                     default, use this toggle only if
  100.                                         you get snow on your monitor
  101.  
  102.         ESC            exits the swap table
  103.  
  104.  
  105. All values in the swap table must be entered as a hex value ranging from 00
  106. to FF.  The original character and its mapped character are shown at the
  107. bottom of the screen.  This line also displays the two or three letter
  108. abbreviation for the ASCII control codes (these are the first 31 characters
  109. of the ASCII character set, from 00 - 1F hex).
  110.  
  111.    After setting up the swap table for your new filter, you will be shown
  112. the current status of the NULL handler.  Use the space bar to toggle
  113. between keeping and stripping NULLs, and hit Enter to accept the new
  114. setting.  You will then be shown the current status of the TAB handler, and
  115. can use the space bar to toggle between expanding them or passing them
  116. through.  If you want to expand the tabs, you will be prompted for a number
  117. to use to create the tab stops.  Enter a new value or press Enter to accept
  118. the current setting.  That's all there is to it; the new filter will be
  119. written to disk and you will be returned to DOS.
  120.  
  121.  
  122.  
  123.  
  124.                             Using your Filter
  125.  
  126.    These filters work by taking advantage of redirection and pipes in DOS. 
  127. All the references to character streams so far may be a little confusing,
  128. so here's a brief explanation.  DOS treats all files as streams of bytes. 
  129. DOS also treats keyboard input, or stdin,  and console output, or stdout,
  130. as files.  Redirection takes advantage of this fact, and remaps stdin or
  131. stdout to point to a regular file instead of the keyboard or monitor.  To
  132. redirect input, add a left arrow (Shift ,) to the name of the file you want
  133. to use as an input file.  To redirect stdout, add a right arrow (Shift .)
  134. to a valid DOS filename.  That file will be created and output intended for
  135. stdout will go there rather than to the monitor.
  136.  
  137.    The filters created with FDK take advantage of DOS redirection.  They
  138. actually get their input from stdin, and output the changed stream to
  139. stdout.  You can verify this by running the filter called CAPS.EXE supplied
  140. with the FDK.  If you run CAPS with no argument, the program will accept
  141. anything you type at the keyboard as input, and will change any lowercase
  142. letters to uppercase every time you press Enter (try it if you want; stop
  143. the program with a Ctrl-C).  By using redirection, you can use any DOS file
  144. as an input, and place the output in a new file.  If you have not used
  145. redirection before, try using it to change sample text file provided with
  146. the FDK to all caps.  Enter the following at the DOS prompt:
  147.  
  148.       CAPS <lower.txt >upper.txt
  149.  
  150. LOWER.TXT is a text file containing all lowercase characters.  After
  151. running LOWER through the filter CAPS, all the letters will be changed to
  152. uppercase and placed in the file UPPER.TXT.  LOWER.TXT itself is unchanged.
  153. Any filter you create with FDK can be used in the same way.
  154.  
  155.     There is also one other way to use these filters - through the use of
  156. pipes.  Pipes take their input from the output of another program.  Pipes
  157. are specified by using the vertical bar (|) before the name of the program
  158. that is to receive the output.  You can try out an FDK filter using a pipe
  159. by entering the following at the DOS prompt:
  160.  
  161.       TYPE lower.txt |caps
  162.  
  163. The result is the same as in the previous example, except that the
  164. transformed file is displayed on the monitor rather than saved to a file. 
  165. Using your filter with pipes is useful for viewing files that would
  166. normally be unreadable.  You can also chain pipes, by placing them one
  167. after the other on the